<?xml version="1.0"?>

<xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:ds="http://www.elixirtech.com/DataSource">
  
  <xsl:template match="/">
    <xsl:element name="root">
  	  <xsl:apply-templates select="//ds:record"/>
	</xsl:element>
  </xsl:template>
  
  <xsl:template match="ds:record">
    <xsl:element name="record">
      <xsl:apply-templates select="ds:field"/>
	</xsl:element>
  </xsl:template>

  
  <!-- this template makes each field a child element with the name taken from the schema -->
  <xsl:template match="ds:field">
    <xsl:variable name="pos" select="position()"/>
    <xsl:variable name="n"><xsl:value-of select="//ds:column[$pos]/@name"/></xsl:variable>
    <xsl:element name="{$n}">
      <xsl:value-of select="."/>
	</xsl:element>
  </xsl:template>

  <!-- this template makes each field an attribute with the name taken from the schema -->
  <!-- xsl:template match="ds:field">
    <xsl:variable name="pos" select="position()"/>
    <xsl:variable name="n"><xsl:value-of select="//ds:column[$pos]/@name"/></xsl:variable>
    <xsl:attribute name="{$n}">
      <xsl:value-of select="."/>
	</xsl:attribute>
  </xsl:template -->
  
</xsl:stylesheet>

